<?php
declare(strict_types=1);
/**
 * MineAdmin is committed to providing solutions for quickly building web applications
 * Please view the LICENSE file that was distributed with this source code,
 * For the full copyright and license information.
 * Thank you very much for using MineAdmin.
 *
 * @Author X.Mo<root@imoi.cn>
 * @Link   https://gitee.com/xmo/MineAdmin
 */
namespace Plugin\Attractions\Commerce\Request\Commerce_commodity;

use Hyperf\Validation\Request\FormRequest;

/**
 * 商品验证数据类
 */
class CommerceCommodityRequest extends FormRequest
{

    public function authorize(): bool
    {
        return true;
    }


    /**
     * 新增数据验证规则
     * return array
     */
    public function rules(): array
    {
        return [
            //商户名称 验证
            'merchant_id' => 'required',
            //计量单位 验证
            'commodity_unit' => 'required',
            'commodity_name' => 'required',
            'commodity_category' => 'required',
            'sale_price' => 'required',

        ];
    }


    /**
     * 字段映射名称
     * return array
     */
    public function attributes(): array
    {
        return [
            'id' => '主键ID',
            'merchant_id' => '商户ID',
            'commodity_name' => '商品名称',
            'commodity_category' => '商品分类',
            'commodity_unit' => '计量单位',
            'discount' => '折扣',
            'stock_quantity' => '库存数量',
            'status' => '商品状态：1-上架，2-下架',
            'sort_order' => '排序',
            'sale_price' => '销售价格',

        ];
    }

public function messages(): array
{
    return [
            'id.required' => '必填主键ID',
            'merchant_id.required' => '必填商户ID',
            'commodity_name.required' => '必填商品名称',
            'commodity_category.required' => '必填商品分类',
            'commodity_unit.required' => '必填计量单位',
            'discount.required' => '必填折扣',
            'stock_quantity.required' => '必填库存数量',
            'status.required' => '必填商品状态：1-上架，2-下架',
            'sort_order.required' => '必填排序',
            'sale_price.required' => '必填销售价格',

    ];
}
}